<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        function ajaxObject() {
            var xmlHttp;
            try {
                // Firefox, Opera 8.0+, Safari
                xmlHttp = new XMLHttpRequest();
            }
            catch (e) {
                // Internet Explorer
                try {
                    xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
                } catch (e) {
                    try {
                        xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
                    } catch (e) {
                        alert("您的浏览器不支持AJAX！");
                        return false;
                    }
                }
            }
            return xmlHttp;
        }

        // ajax post请求：
        function ajaxPost(url, data, fnSucceed, fnFail, fnLoading) {
            var ajax = ajaxObject();
            ajax.open("post", url, true);
            ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
            ajax.onreadystatechange = function () {
                if (ajax.readyState == 4) {
                    if (ajax.status == 200) {
                        console.log(ajax.responseText);
                        fnSucceed(ajax.responseText);
                    }
                    else {
                        fnFail("HTTP请求错误！错误码：" + ajax.status);
                    }
                }
                else {
                    // fnLoading();
                }
            }
            ajax.send(data);
        }
        let data ={

        }
        ajaxPost("http://api/v1/turistlogin",data,(e)=>{
            console.log(e);
        },(w)=>{
            alert(w);
        })
    </script>
</body>

</html>